EEG Analysis: Epilepsy in pediatric patients

Background

In this notebook we will be analyzing data of pediatric patients with epilepsy. This data is of free acces and can be downloaded from https://openneuro.org/datasets/ds003555/versions/1.0.1/download. The dataset of EEG recordings contains HFO markings for 30 pediatric patients with epilepsy. All the recordings were made with the 10-20 system.

Our objective is to create an algorithm able to detect when an epileptic attack occurs. We know that epileptic seizures occur mostly during the N2 and N3 sleep stages. So the first step would be to be able to divide the recordings in sleep stages

Altought the divition of may vary among different authors, we are able to make a correlation of stages basen on the description of each. Here we will work with the following stages: Awake, N1, N2, N3, REM. This convention is preffered because the data we will use is already marked with those stages, so validation will be easier.

Brain activity is usually classified by frequency. There are 5 main types of waves: delta, theta, alpha, beta and gamma, with delta being the one with the lowest frequency and gamma the one with the highest frequency. In the following table we have a summary of how every type of wave is involved in a given sleep stage.

</tr>

</tr>

</tr>

</tr>

</tr>

</tr>
</table> Information obtained from 3, 4, 5.

Delta waves: 0.2-4 Hz Theta waves: 4-8 Hz Alpha waves: 8-12 Hz Beta waves: 12-30 Hz
Awake Dominant rhythm over the occipital regions Main component in anterior leads
N1 Main activity Disappearance of the alpha rhythm
N2 Bilaterally synchronous theta activity Sleep spindles or k waves may appear
N3 Slow Delta waves K-complexes and sleep spindles may be present
REM Sawtooth waves are seen (2-6 Hz) Similar to N1 activity
Measurement date February 28, 2021 22:51:37 GMT
Experimenter Unknown
Participant Unknown
Digitized points 0 points
Good channels 23 EEG
Bad channels None
EOG channels Not available
ECG channels Not available
Sampling frequency 1024.00 Hz
Highpass 0.40 Hz
Lowpass 80.00 Hz
Filenames sub-03_ses-01_task-hfo_eeg.edf
Duration 02:59:59 (HH:MM:SS)

Now we will remove the 50 Hz noise. We must remember that it is important to apply a band stop filter at the main frequency AND its multiples. In this case we only need to apply 2 notch filters at 50 Hz and 100 Hz.

Frontal vs central vs parietal electrodes

In the last 3 PSDs it can be observed that the central electrodes don't share a general shape of spectral density with the frontal electrodes nor with the parietal electrodes. This means that even though the central electrodes don't correspond to a cerebral lobe, they should be treated as independent.

Loading the data

By default, MNE does not load data into main memory to conserve resources. inst.filter requires raw data to be loaded.

Note that the events are given with the channel names of the derivatives and the indexes correspond to the sampling frequency of the derivative resamling at 2 000 Hz.

Events

Dividing the run in segments

For the first test we will compute the area under the curve(which corresponds to the relative band energy of the segment for a specific chanel in a specific segment), the mean amplitude for each band, the frequency at which the SPD of a band reaches a maximum and the frequency at which the SPD of a band reaches a minimum. These parameter should be able to characterise the shape of the SPD.

In total we would have 23 chanels, each with 5 frequency bands(delta, theta, alpha, beta and gamma), each with 4 parameters. This means each segment has 460 parameters that describe the funcion.

Relative band energy

To have an idea of how valueable a parameter is, we will plot them with markings of the sleep stages. First we will plot the relative band energy (area under the curve).

Mean value

Now you will try the other two variables and observe if there is a notable change between sleep stages.

Welch plots

Derivative channels

In the source of the data we are using there is a folder named "derivatives". This file contains bipolar derivations of the original data. This derivations were obtained by a resampling of the data. The are also files of marked events within the bipolar derivation. Now we will try to obtain the same information as before but with this new channels.

The bipolar derivations used correspond to the "double banana" derivations. In this derivation 5 main antero-posterior chains of electrodes are created forming the shape of a double banana. By ploting this bipolar derivations we are able to watch the flow of current though the brain. Sometimes two adjasent links of a chain of electrodes have a similar spike but inverted. This type of phenomenon is called a phase reversal and is very useful in detection of epilepiform activity and artifact detection.

5e8ad2dca6b2c1434cac8025_Double_Banana_Setup_%28flat%29-17-p-1080.png

Plot of derivative chanels

Properties of derivative chanels

For the deriatives we will obtain the relative band energy, the mean intensity of the PSD and the frequency at which the median is found.

Results

 Recap of functions:

Bibliography:

  1. Dorottya Cserpan and Ece Boran and Richard Rosch and San Pietro Lo Biundo and Georgia Ramantani and Johannes Sarnthein (2021). Dataset of EEG recordings of pediatric patients with epilepsy based on the 10-20 system . OpenNeuro. [Dataset] doi: 10.18112/openneuro.ds003555.v1.0.1
  2. The Normal Asleep EEG. (2022, July 13). Retrieved from https://www.learningeeg.com/normal-asleep
  3. Nayak CS, Anilkumar AC. EEG Normal Sleep. [Updated 2022 May 8]. In: StatPearls [Internet]. Treasure Island (FL): StatPearls Publishing; 2022 Jan-. Available from: https://www.ncbi.nlm.nih.gov/books/NBK537023/
  4. Normal Sleep EEG: Overview, Stage I Sleep, Stage II Sleep. (2022, March 11). Retrieved from https://emedicine.medscape.com/article/1140322-overview
  5. Diykh, M., & Li, Y. (2016). Complex networks approach for EEG signal sleep stages classification. Expert Syst. Appl., 63, 241–248. doi: 10.1016/j.eswa.2016.07.004
  6. Estrada, E., Nazeran, H., Nava, P., Behbehani, K., Burk, J., & Lucas, E. (2004). EEG feature extraction for classification of sleep stages. The 26th Annual International Conference of the IEEE Engineering in Medicine and Biology Society. IEEE. doi: 10.1109/IEMBS.2004.1403125
  7. Van Hese, P., Philips, W., De Koninck, J., Van de Walle, R., & Lemahieu, I. (2001). Automatic detection of sleep stages using the EEG. 2001 Conference Proceedings of the 23rd Annual International Conference of the IEEE Engineering in Medicine and Biology Society. IEEE. doi: 10.1109/IEMBS.2001.1020608
  8. Diykh, M., & Li, Y. (2016). Complex networks approach for EEG signal sleep stages classification. Expert Syst. Appl., 63, 241–248. doi: 10.1016/j.eswa.2016.07.004